import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { getWeekMonthQuarterYear } from '/@/utils';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '门店编码',
    align:"center",
    dataIndex: 'storeCode'
   },
   {
    title: '门店名称',
    align:"center",
    dataIndex: 'storeName'
   },
   {
    title: '所属客户',
    align:"center",
    dataIndex: 'customerId_dictText'
   },
   {
    title: '省市区',
    align:"center",
    dataIndex: 'province',
   },
   {
    title: '门店详细地址',
    align:"center",
    dataIndex: 'storeAddress'
   },
   {
    title: '门店地址经纬度',
    align:"center",
    dataIndex: 'storeCoordinates'
   },
   {
    title: '门店面积',
    align:"center",
    dataIndex: 'storeArea'
   },
   {
    title: '门店负责人',
    align:"center",
    dataIndex: 'storeManager'
   },
   {
    title: '门店负责人电话',
    align:"center",
    dataIndex: 'storeManagerPhone'
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '门店编码',
    field: 'storeCode',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: false, message: '请输入门店编码!'},
          ];
     },
    dynamicDisabled:true
  },
  {
    label: '门店名称',
    field: 'storeName',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入门店名称!'},
          ];
     },
  },
  {
    label: '所属客户',
    field: 'customerId',
    component: 'JSearchSelect',
    componentProps:{
       dict:"xl_customer_info,customer_name,id"
    },
  },
  {
    label: '省市区',
    field: 'province',
    component: 'JAreaLinkage',
    componentProps: {
      saveCode: 'region',
    },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入省!'},
          ];
     },
  },
  {
    label: '门店详细地址',
    field: 'storeAddress',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入门店系统地址!'},
          ];
     },
  },
  {
    label: '门店地址经纬度',
    field: 'storeCoordinates',
    component: 'Input',
    show: false
  },
  {
    label: '门店面积',
    field: 'storeArea',
    component: 'Input',
  },
  {
    label: '门店负责人',
    field: 'storeManager',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入门店负责人!'},
          ];
     },
  },
  {
    label: '门店负责人电话',
    field: 'storeManagerPhone',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入门店负责人电话!',  pattern: /^1[3456789]\d{9}$/},
          ];
     },
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];

// 高级查询数据
export const superQuerySchema = {
  storeCode: {title: '门店编码',order: 0,view: 'text', type: 'string',},
  storeName: {title: '门店名称',order: 1,view: 'text', type: 'string',},
  customerId: {title: '客户ID',order: 2,view: 'number', type: 'number',dictTable: "xl_customer_info", dictCode: 'id', dictText: 'customer_name',},
  province: {title: '省',order: 3,view: 'pca', type: 'string',},
  storeAddress: {title: '门店系统地址',order: 4,view: 'text', type: 'string',},
  storeCoordinates: {title: '门店地址经纬度',order: 5,view: 'text', type: 'string',},
  storeArea: {title: '门店面积',order: 6,view: 'text', type: 'string',},
  storeManager: {title: '门店负责人',order: 7,view: 'text', type: 'string',},
  storeManagerPhone: {title: '门店负责人电话',order: 8,view: 'text', type: 'string',},
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}